/**
 * Constructs a new User
 * @param {Object} username
 * @param {Object} password
 * @param {Object} firstname
 * @param {Object} lastname
 */
User.prototype.constructor = function(username, password, firstname, lastname) {
   // check if a User exists
   if (root.get(username)) {
      throw "User already exists!";
   }
   
   if (!/^\w+$/.test(username)) {
      throw "Invalid username!";
   }
   
   // set the properties
   this.username = username;
   this.password = password;
   this.firstname = firstname;
   this.lastname  = lastname;
   
   return;
}

User.prototype.canEdit = function() {
   return session.user == this;
}
